package com.atguigui.leetcode1;

/**
 * 2180.统计各位数字之和为偶数的整数个数
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/1/6 8:49
 */
public class P2180CountIntegersWithEvenDigitSum {
    public static void main(String[] args) {
        Solution solution = new P2180CountIntegersWithEvenDigitSum().new Solution();
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int countEven(int num) {
            int res = 0;
            for (int i = 1; i <= num; i++) {
                int x = i, sum = 0;
                while (x != 0) {
                    //对位取模，位数相加
                    sum += x % 10;
                    x /= 10;
                }
                if (sum % 2 == 0) {
                    res++;
                }
            }
            return res;
        }
    }
}
